package com.foton.logistic.util;

import android.content.Context;
import android.content.Intent;

import com.baidu.location.BDLocation;
import com.foton.logistic.model.SelectEntity;
import com.foton.logistic.push.PushMessageResult;

public class BroadcastUtil {

    /**
     * 发送定位结果广播
     * @param context
     * @param bdLocation
     */
    public static void sendLocLocationBroadcast(Context context, BDLocation bdLocation){
        try {
            Intent intent = new Intent();
            intent.setAction(BaseConstant.ACTION_LOCATION_LOC);
            intent.putExtra(BaseConstant.INTENT_CONTENT,bdLocation);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 消息推送通知广播
     * @param context
     * @param pushMessageResult
     */
    public static void sendPushMessageBroadcast(Context context, PushMessageResult pushMessageResult){
        try {
            Intent intent = new Intent();
            intent.putExtra(BaseConstant.INTENT_CONTENT,pushMessageResult);
            intent.setAction(BaseConstant.ACTION_MESSAGE);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 消息推送绑定广播
     * @param context
     * @param userId
     * @param channelId
     */
    public static void sendPushBroadcast(Context context, String userId, String channelId){
        try {
            Intent intent = new Intent();
            intent.putExtra(BaseConstant.INTENT_ARG,userId);
            intent.putExtra(BaseConstant.INTENT_CONTENT,channelId);
            intent.setAction(BaseConstant.ACTION_PUSH);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void sendTabOrder(Context context,int type){
        try {
            Intent intent = new Intent();
            intent.putExtra(BaseConstant.INTENT_TYPE,type);
            intent.setAction(BaseConstant.ACTION_HOME);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 记录筛选广播
     */
    public static void sendSelectBroadcast(Context context,SelectEntity selectEntity){
        try {
            Intent intent = new Intent();
            intent.putExtra(BaseConstant.INTENT_SELECT,selectEntity);
            intent.setAction(BaseConstant.ACTION_SELECT_FILTER);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public static void sendShopBroadcast(Context context,SelectEntity selectEntity){
        try {
            Intent intent = new Intent();
            intent.putExtra(BaseConstant.INTENT_SELECT,selectEntity);
            intent.setAction(BaseConstant.ACTION_SELECT_FILTER);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 发送订单刷新广播
     * @param context
     */
    public static void sendOrderRefreshBroadcast(Context context){
        try {
            Intent intent = new Intent();
            intent.setAction(BaseConstant.ACTION_ORDER_REFRESH);
            context.sendBroadcast(intent);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public static void sendEditEnble(Context context,int type){
        try {
            Intent intent = new Intent();
            intent.setAction(BaseConstant.ACTION_ENBLE);
            intent.putExtra(BaseConstant.INTENT_TYPE,type);
            context.sendBroadcast(intent);

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
